/**
 * Created by aa on 2016/9/21.
 *
 * 此文件夹仲的文件用于将后端的数据设配为前端适用的数据格式，抽取出可重用的部分，便于管理
 */
exports.getListByParIdDataOperate=(result)=> {
    var resultItem={};
    if(result.result) {
        result = result.result[0];
        resultItem = {
            name: result.parName,
            parId: result.parId,
            profit: result.maxYearRate !== result.minYearRate ? result.minYearRate + '-' + result.maxYearRate : result.maxYearRate,
            financingAmount: result.financingAccount,
            surplusAmount: result.sraiseAccount,
            process: (result.yraiseAccount / result.financingAccount * 100).toFixed(2) + '%',
            time: result.proTermStr,
            size: result.size,
            products: []
        };
        for (var j = 0; j < result.productResList.length; j++) {
            var productResList = result.productResList[j];
            var product = [
                productResList.id,
                productResList.name,
                productResList.maxYearRate !== productResList.minYearRate ? productResList.minYearRate + '-' + productResList.maxYearRate : productResList.maxYearRate,
                productResList.proTermStr,
                productResList.sraiseAccount,
                ((productResList.financingAccount - productResList.sraiseAccount) / productResList.financingAccount * 100).toFixed(2) + '%'
            ];
            resultItem.products.push(product);
        }
    }
    return resultItem;
};